#include <stdio.h>

int main()
{
    //把一个ip地址转化为一个整数
    char a[] = "192.168.2.2";
    unsigned int ip = 0;
    unsigned char *p = (unsigned char *)&ip;
    int a1, a2, a3, a4;
    sscanf(a, "%d.%d.%d.%d", &a1, &a2, &a3, &a4);
    printf("%d-%d-%d-%d\n", a1, a2, a3, a4);

    //p[0] = a4;
    //p[1] = a3;
    //p[2] = a2;
    //p[3] = a1;
    
    *p = a4;//把a4的值赋给地址p
    printf("%p\n", p);
    p++;//地址+1
    *p = a3;
    printf("%p\n", p);
    p++;//地址+1
    *p = a2;
    printf("%p\n", p);
    p++;//地址+1
    *p = a1;
    printf("%p\n", p);

    printf("%u\n", ip);
    return 0;
}

